//
//  XDTKAlert_3.m
//  testDemo
//
//  Created by 赵林瑞 on 16/7/25.
//  Copyright © 2016年 RZOL. All rights reserved.
//

#import "XDTKAlert_3.h"


@interface XDTKAlert_3 ()
{
    IBOutlet UIImageView *text1Img;
    IBOutlet UIButton *text1Btn;
    
    IBOutlet UIImageView *text2Img;
    IBOutlet UIButton *text2Btn;
    
    IBOutlet UIImageView *text3Img;
    IBOutlet UIButton *text3Btn;
    
    
    
    IBOutlet NSLayoutConstraint *lineH;
    IBOutlet NSLayoutConstraint *titleH;
    IBOutlet NSLayoutConstraint *imgW;
    IBOutlet NSLayoutConstraint *cancleBtnH;
}

@property (nonatomic, strong) UIButton *selectedBtn;

@end

@implementation XDTKAlert_3

- (void)awakeFromNib {
    
    [self fit];
    
    text1Btn.selected = YES;
    
    self.selectedText = self.text_1.text;
    [self chooseClick];
}

- (void)fit {
    lineH.constant = 0.5;
    titleH.constant = 40*SCREEN_SCALE;
    imgW.constant = 13*SCREEN_SCALE;
    cancleBtnH.constant = 30*SCREEN_SCALE;
    
    self.title.font = LAB_FONT(15);
    self.text_1.font = self.text_2.font = self.text_3.font = LAB_FONT(11);
    self.promptText.font = LAB_FONT(10);
}

- (void)chooseClick {
    if (text1Btn.selected) {
        [text1Img setImage:[UIImage imageNamed:@"tuikuan_xuanzhong"]];
        self.text_1.textColor = HEXCOLOR(0x333333);
    }else{
        [text1Img setImage:[UIImage imageNamed:@"jiekuan-kongyuan"]];
        self.text_1.textColor = HEXCOLOR(0x666666);
    }
    
    
    if (text2Btn.selected) {
        [text2Img setImage:[UIImage imageNamed:@"tuikuan_xuanzhong"]];
        self.text_2.textColor = HEXCOLOR(0x333333);
    }else{
        [text2Img setImage:[UIImage imageNamed:@"jiekuan-kongyuan"]];
        self.text_2.textColor = HEXCOLOR(0x666666);
    }
    
    
    
    if (text3Btn.selected) {
        [text3Img setImage:[UIImage imageNamed:@"tuikuan_xuanzhong"]];
        self.text_3.textColor = HEXCOLOR(0x333333);
    }else{
        [text3Img setImage:[UIImage imageNamed:@"jiekuan-kongyuan"]];
        self.text_3.textColor = HEXCOLOR(0x666666);
    }
}
- (IBAction)choose1:(id)sender {
    text1Btn.selected = YES;
    text2Btn.selected = NO;
    text3Btn.selected = NO;
    
    self.selectedText = self.text_1.text;
    [self chooseClick];
}
- (IBAction)choose2:(id)sender {
    text1Btn.selected = NO;
    text2Btn.selected = YES;
    text3Btn.selected = NO;
    
    self.selectedText = self.text_2.text;
    [self chooseClick];
}
- (IBAction)choose3:(id)sender {
    text1Btn.selected = NO;
    text2Btn.selected = NO;
    text3Btn.selected = YES;
    
    self.selectedText = self.text_3.text;
    [self chooseClick];
}

- (IBAction)cancleClick:(id)sender {
    if (self.cancleBlock) {
        self.cancleBlock();
    }
}
- (IBAction)sureClcik:(id)sender {
    if (self.sureBlock) {
        self.sureBlock(self.selectedText);
    }
}
@end
